/*
CCAP replication material for:
"Personality and Roots of Welfare State Support: How Openness to Experience Moderates the Influence of Self-Interest and Ideology on Redistributive Preferences"

Authors: Tobias Heide-Jørgensen, Peter Thisted Dinesen, and Kim Mannemar Sønderskov.

PURPOSE: Reproducing results based on CCAP data.
*/

*Reading data
use "CCAP_data.dta",clear

*Variable for openness
recode PROFILE49 (1=7) (2=6) (3=5) (5=3) (6=2) (7=1),pre(new_)

gen open=PROFILE44+new_PROFILE49
sum open
replace open = (open-r(min))/(r(max)-r(min))	

alpha PROFILE44 new_PROFILE49 //Alpha

*Variable for extraversion
recode PROFILE45 (1=7) (2=6) (3=5) (5=3) (6=2) (7=1),pre(new_)

gen extrav=PROFILE40+new_PROFILE45

sum extrav
replace extrav = (extrav-r(min))/(r(max)-r(min))	

alpha PROFILE40 new_PROFILE45 //Alpha

*Variable for agreeableness
recode PROFILE41 (1=7) (2=6) (3=5) (5=3) (6=2) (7=1),pre(new_)

gen agree=new_PROFILE41+PROFILE46

sum agree
replace agree = (agree-r(min))/(r(max)-r(min))	

alpha new_PROFILE41 PROFILE46 //Alpha

*Variable for conscientiousness
recode PROFILE47 (1=7) (2=6) (3=5) (5=3) (6=2) (7=1),pre(new_)

gen cons=PROFILE42+new_PROFILE47

sum cons
replace cons = (cons-r(min))/(r(max)-r(min))	

alpha PROFILE42 new_PROFILE47 //Alpha

*Variable for emotional stability
recode PROFILE43 (1=7) (2=6) (3=5) (5=3) (6=2) (7=1),pre(new_)

gen emo=new_PROFILE43+PROFILE48

sum emo
replace emo = (emo-r(min))/(r(max)-r(min))	

alpha new_PROFILE43 PROFILE48 //Alpha

*Variable for attitudes toward redistribution
recode BCAP24 (1=4) (2=3) (3=2) (4=1) (5=.),gen(redis)

sum redis
replace redis = (redis-r(min))/(r(max)-r(min))	

*Variable for income
recode PROFILE59 (15=.),gen(inc)

label value inc labels319

*Variable for liberal-conservative self-identification
recode BCAP700s (6=.),gen(ideo)

sum ideo
replace ideo = (ideo-r(min))/(r(max)-r(min))	

label var ideo "Liberal/conservative identification"

*Variable for age
gen age=2008-PROFILE51

*Multiple imputations			
mi set flong							

mi register imputed redis ideo open inc PROFILE58 PROFILE60 agree extrav emo cons			
mi register regular PROFILE55 age PROFILE57 PROFILE54 OCAP300LIBS OCAP300CONS PCAP600 PROFILE66  		
			
mi impute chained (ologit) inc (mlogit) PROFILE58 PROFILE60 (reg) redis ideo open emo extrav cons agree = PROFILE55 age PROFILE57 PROFILE54 OCAP300LIBS OCAP300CONS PCAP600 PROFILE66, add(10) rseed(1234) augment force	

mi passive: gen inc_3_mi=.
mi passive: replace inc_3_mi=1 if inrange(inc,1,6)
mi passive: replace inc_3_mi=2 if inrange(inc,7,10)
mi passive: replace inc_3_mi=3 if inrange(inc,11,14)

label var inc_3_mi "Family income"

label define inc_3_mi 1 "Low income" 2 "Medium income" 3 "High income"
label values inc_3_mi inc_3_mi

*Primary analyses: income							
mi estimate, dots: reg redis inc_3_mi##c.open i.PROFILE54 i.PROFILE57 c.age##c.age i.PROFILE55 i.PROFILE58 i.PROFILE60 emo cons extrav agree,robust
mi test 2.inc_3#c.open 3.inc_3#c.open

*Primary analyses: ideology							
mi estimate, dots: reg redis c.ideo##c.open i.inc i.PROFILE54 i.PROFILE57 c.age##c.age i.PROFILE55 i.PROFILE58 i.PROFILE60 agree extrav emo cons,robust

*Analyses with other personality traits: income							
mi estimate, dots: reg redis inc_3_mi##c.cons i.PROFILE54 i.PROFILE57 c.age##c.age i.PROFILE55 i.PROFILE58 i.PROFILE60 open emo extrav agree,robust

mi estimate, dots: reg redis inc_3_mi##c.emo i.PROFILE54 i.PROFILE57 c.age##c.age i.PROFILE55 i.PROFILE58 i.PROFILE60 open extrav agree cons,robust

mi estimate, dots: reg redis inc_3_mi##c.extrav i.PROFILE54 i.PROFILE57 c.age##c.age i.PROFILE55 i.PROFILE58 i.PROFILE60 open emo agree cons,robust

mi estimate, dots: reg redis inc_3_mi##c.agree i.PROFILE54 i.PROFILE57 c.age##c.age i.PROFILE55 i.PROFILE58 i.PROFILE60 open emo extrav cons,robust

*Analyses with other personality traits: ideology							
mi estimate, dots: reg redis c.ideo##c.cons i.inc i.PROFILE54 i.PROFILE57 c.age##c.age i.PROFILE55 i.PROFILE58 i.PROFILE60 open agree extrav emo,robust

mi estimate, dots: reg redis c.ideo##c.emo i.inc i.PROFILE54 i.PROFILE57 c.age##c.age i.PROFILE55 i.PROFILE58 i.PROFILE60 open agree extrav cons,robust

mi estimate, dots: reg redis c.ideo##c.extrav i.inc i.PROFILE54 i.PROFILE57 c.age##c.age i.PROFILE55 i.PROFILE58 i.PROFILE60 open agree emo cons,robust

mi estimate, dots: reg redis c.ideo##c.agree i.inc i.PROFILE54 i.PROFILE57 c.age##c.age i.PROFILE55 i.PROFILE58 i.PROFILE60 open agree extrav cons,robust
